
package com.dps.zain.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.broadvision.portal.services.PortalVisitor;
import com.broadvision.visitor.exceptions.VisitorException;
import com.broadvision.web.servlet.SessionVisitor;
import com.dps.dao.channel.ChannelDao;

/**
 * @author hassan.naqvi
 * @edited August 03, 2008
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ViewSubChannelAction extends Action {

	// --------------------------------------------------------- Instance Variables

	// --------------------------------------------------------- Methods

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) {

		System.out.println("Entering into class: "+ this.getClass());
		String channelId = request.getParameter("channelId");
		String mappings = "";
		SessionVisitor sessionVisitor = SessionVisitor.getInstance(request.getSession());
		ChannelDao channel=new ChannelDao(sessionVisitor);
		List channels = channel.getSubChannels(channelId);
		request.setAttribute("subChannels",channels);
	    request.setAttribute("parentChannel",channelId);
		request.setAttribute("channelId",channelId);
		mappings = "viewChannels";
		return mapping.findForward(mappings);
		
	}

}